package com.kma.summer2012.client.presenters.authorization;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Widget;
import com.kma.summer2012.client.CrumbsEventBus;
import com.kma.summer2012.client.events.authorization.LoginEvent;
import com.kma.summer2012.client.presenters.Presenter;

public class ConfirmPasswordPresenter implements Presenter {
    public interface Display {
        HasClickHandlers getHome();

        Widget asWidget();
    }

    private final Display display;

    public ConfirmPasswordPresenter(Display display) {
        this.display = display;
        bind();
    }

    private void bind() {
        this.display.getHome().addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent clickEvent) {
                CrumbsEventBus.getInstance().fireEvent(new LoginEvent());
            }
        });
    }

    @Override
    public void go(HasWidgets container) {
        container.clear();
        container.add(display.asWidget());
    }
}
